#ifndef __GESTURE_H__
#define __GESTURE_H__

#include "cocos2d.h"
USING_NS_CC;

namespace suta
{
	class Gesture:public CCLayer
	{
		CCPoint m_srcPoint;
	public:
		bool init(CCPoint&srcPoint)
		{
			bool ret=false;
			do 
			{
				CC_BREAK_IF(!CCLayer::init());
				setContentSize(CCSizeMake(50,50));
				setIsRelativeAnchorPoint(true);
				m_srcPoint.x=srcPoint.x;
				m_srcPoint.y=srcPoint.y;

				CCSprite*gesture=CCSprite::spriteWithFile("gesture.png");
				gesture->setPosition(ccp(25,25));
				addChild(gesture);

				setPosition(m_srcPoint);

				CCMoveTo*move=CCMoveTo::actionWithDuration(1.2f,ccp(m_srcPoint.x-200,m_srcPoint.y+180));
				CCCallFunc*call=CCCallFunc::actionWithTarget(this,callfunc_selector(Gesture::reset));
				CCDelayTime*delay=CCDelayTime::actionWithDuration(0.3f);
				CCFiniteTimeAction*seq=CCSequence::actions(move,delay,call,NULL);
				CCRepeat*repeat=CCRepeat::actionWithAction(seq,3);
				CCCallFunc*callHide=CCCallFunc::actionWithTarget(this,callfunc_selector(Gesture::hide));
				CCSequence*seqAll=CCSequence::actionOneTwo(repeat,callHide);
				runAction(seqAll);

				ret=true;
			} while (0);
			return ret;
		};

		LAYER_NODE_FUNC_PARAM(Gesture,CCPoint&,srcPoint);

		inline void reset(){setPosition(m_srcPoint);};
		inline void hide(){setIsVisible(false);};
	};
}

#endif//__GESTURE_H__